<div ng-controller="ordersCtrl">
    <div class="bg-light lter b-b wrapper-md ng-scope">
        <h4 class="m-n font-thin">待结算订单管理</h4>
    </div>
    <div class="wrapper-md">
        <div class="panel">
            <div class="row wrapper">
                <div class="col-sm-9">
                    <form class="form-inline ng-pristine ng-valid">
                        <div class="block m-t-sm">
                            <label class="control-label">下单时间</label>
                            <div class="input-group" ng-controller="DatepickerDemoCtrl">
                                <div class="input-group  no-padder m-n w-lg">
                                    <input type="text" class="input-sm form-control" placeholder="请输入开始日期" uib-datepicker-popup="yyyy-MM-dd" datepicker-popup="yyyy-MM-dd" ng-model="orders.buyStartDate"
                                           alt-input-formats="altInputFormats" is-open="opened" datepicker-options="dateOptions" close-text="关闭" clear-text="清空" current-text="今天"/>
                                    <span class="input-group-btn ">
                                        <button type="button" class="input-sm btn btn-default" ng-click="open($event)"><i class="glyphicon glyphicon-calendar"></i></button>
                                    </span>
                                </div>
                            </div>
                            <div class="input-group" ng-controller="DatepickerDemoCtrl">
                                <div class="input-group  no-padder m-n w-lg">
                                    <input type="text" class="input-sm form-control" placeholder="请输入结束日期" uib-datepicker-popup="yyyy-MM-dd" datepicker-popup="yyyy-MM-dd" ng-model="orders.buyEndDate"
                                           alt-input-formats="altInputFormats" is-open="opened" datepicker-options="dateOptions" close-text="关闭" clear-text="清空" current-text="今天" min-date="orders.buyStartDate"/>
                                    <span class="input-group-btn ">
                                        <button type="button" class="input-sm btn btn-default" ng-click="open($event)"><i class="glyphicon glyphicon-calendar"></i></button>
                                    </span>
                                </div>
                            </div>
                        </div>
                        <div class="block m-t-sm">
                            <label class="control-label">付款时间</label>
                            <div class="input-group" ng-controller="DatepickerDemoCtrl">
                                <div class="input-group  no-padder m-n w-lg">
                                    <input type="text" class="input-sm form-control" placeholder="请输入开始日期" uib-datepicker-popup="yyyy-MM-dd" datepicker-popup="yyyy-MM-dd" ng-model="orders.startDate"
                                           alt-input-formats="altInputFormats" is-open="opened" datepicker-options="dateOptions" close-text="关闭" clear-text="清空" current-text="今天"/>
                                    <span class="input-group-btn ">
                                        <button type="button" class="input-sm btn btn-default" ng-click="open($event)"><i class="glyphicon glyphicon-calendar"></i></button>
                                    </span>
                                </div>
                            </div>
                            <div class="input-group" ng-controller="DatepickerDemoCtrl">
                                <div class="input-group  no-padder m-n w-lg">
                                    <input type="text" class="input-sm form-control" placeholder="请输入结束日期" uib-datepicker-popup="yyyy-MM-dd" datepicker-popup="yyyy-MM-dd" ng-model="orders.endDate"
                                           alt-input-formats="altInputFormats" is-open="opened" datepicker-options="dateOptions" close-text="关闭" clear-text="清空" current-text="今天" min-date="orders.startDate"/>
                                    <span class="input-group-btn ">
                                        <button type="button" class="input-sm btn btn-default" ng-click="open($event)"><i class="glyphicon glyphicon-calendar"></i></button>
                                    </span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group block m-t-sm">
                            <div class="form-group">
                                <label class="control-label">店铺订单编号</label>
                                <input type="text" ng-model="orders.shopOrderNumber" class="input-sm form-control">
                            </div>
                            <div class="form-group">
                                <label class="control-label">手机号码</label>
                                <input type="text" ng-model="orders.mobilePhone" class="input-sm form-control">
                            </div>
                            <div class="form-group">
                                <label class="control-label">收货人</label>
                                <input type="text" ng-model="orders.addressName" class="input-sm form-control">
                            </div>
                        </div>
                        <input type="hidden" ng-model="orders.pageType" ng-init="orders.pageType = 1" >
                        <button class="btn btn-sm btn-info" ng-click="query()">查询</button>
                    </form>
                </div>
                <div class="clearfix"></div>
            </div>
            <div class="table-responsive">
                <table class="table table-striped b-t b-light">
                    <thead>
                    <tr>
                        <th>所属门店</th>
                        <th>店铺订单编号</th>
                        <th>用户信息</th>
                        <th>物流信息</th>
                        <th width="170">订单金额</th>
                        <th>优惠金额</th>
                        <th width="90">支付方式</th>
                        <th width="220">操作时间</th>
                        <th>状态</th>
                        <th width="140" class="text-center">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr ng-repeat="o in list">
                        <td>
                            {{o.shopName}}
                            <i class="m-l-xs fa fa-question-circle text-success pos-rlt h6" popover-placement="top"
                               popover="订单备注：{{o.remark}}" popover-trigger="mouseenter" ng-if="o.remark != null && o.remark!=''"></i>
                        </td>
                        <td>{{o.shopOrderNumber}}</td>
                        <td ng-if="o.type ==1 || o.type ==2">
                            <span>收货人：{{o.userName}}</span></br>
                            <span>手机号码：{{o.mobilePhone}}</span></br>
                            <span>地址：{{o.area}} {{o.address}}</span>
                        </td>
                        <td ng-if="o.type == 0|| o.type ==3 || o.type ==4 || o.type==5">
                            <span>收货人：{{o.name}}</span></br>
                            <span>手机号码：{{o.userMobilePhone}}</span>
                        </td>
                        <td>
                            <label class="inline" ng-if="o.logisticsNumber != null && o.logisticsName != null">
                                <span class="block m-b-xs">物流公司:{{o.logisticsName}}<br>物流单号：{{o.logisticsNumber}}</span>
                                <a class="h6 text-success m-t-sm"  ng-click="logisticsTrace(o.logisticsNumber,o.logisticsCode)"><i class="fa fa-dot-circle-o m-r-xs"></i>查看物流详情</a>
                            </label>
                            <label class="inline" ng-if="o.logisticsNumber == null && o.logisticsName == null">
                                <span class="block m-b-xs">暂无物流信息</span>
                            </label>
                        </td>
                        <td>订单金额：{{o.realMoney | number:2}} 元<br>
                            <span ng-if="o.type == 2">运费：{{o.postage | number:2}} 元<br></span>
                            <span ng-if="o.type == 1">配送费：{{o.postage | number:2}} 元<br></span>
                            <span ng-if="o.type == 1 || o.type == 5">餐盒费：{{o.foodBoxCharge | number:2}} 元<br></span>
                            <span>支付金额：{{o.payMoney | number:2}} 元<br></span>
                            <span>差价：{{o.priceDifference | number:2}} 元</span>
                        </td>
                        <td>
                            <span>优惠券：{{o.couponsMoney | number:2}}  元<br></span>
                            <span ng-if="o.privilegeMoney!=null">会员卡：{{o.privilegeMoney | number:2}} 元<br></span>
                            <span ng-if="o.privilegeMoney==null">会员卡：0.00 元<br></span>
                            <span>乐积分：{{o.deductionMoney | number:2}} 元</span>
                        </td>
                        <td>
                            <span class="badge bg-success" ng-if="o.payWay == 0">微信</span>
                            <span class="badge bg-danger" ng-if="o.payWay == 1">现金分</span>
                            <span class="badge bg-warning" ng-if="o.payWay == 2">积分</span>
                            <span class="badge bg-info" ng-if="o.payWay == 3">会员卡</span>
                        </td>
                        <td>
                            <span ng-if="o.createdTime != null">下单时间：{{o.createdTime}}<br></span>
                            <span ng-if="o.payTime != null">付款时间：{{o.payTime}}<br></span>
                            <span ng-if="o.acceptTime != null">接单时间：{{o.acceptTime}}<br></span>
                            <span ng-if="o.deliveryTime != null && o.type == 2">发货时间：{{o.deliveryTime}}<br></span>
                            <span ng-if="o.deliveryTime != null && o.type == 1">配送时间：{{o.deliveryTime}}<br></span>
                            <span ng-if="o.useTime != null">核销时间：{{o.useTime}}<br></span>
                            <span ng-if="o.confirmTime != null">确认时间：{{o.confirmTime}}<br></span>
                            <span ng-if="o.completeTime != null">完成时间：{{o.completeTime}}</span>
                        </td>
                        <td>
                            <span class="label bg-warning" ng-if="o.status == 0">未付款</span>
                            <span class="label bg-danger" ng-if="o.status == 1">已付款</span>
                            <span class="label bg-info" ng-if="o.status == 2">已发货</span>
                            <span class="label bg-primary" ng-if="o.status == 3">确认收货/待评价</span>
                            <span class="label bg-warning" ng-if="o.status == 4">待使用</span>
                            <span class="label bg-success" ng-if="o.status == 5">已使用</span>
                            <span class="label bg-success" ng-if="o.status == 6">交易完成</span>
                            <span class="label bg-light" ng-if="o.status == 7">交易取消</span>
                            <span class="label bg-danger" ng-if="o.status == 8">退货中</span>
                            <span class="label bg-light" ng-if="o.status == 9">退款/退货完成</span>
                        </td>
                        <td class="t-btns text-left">
                            <button class="btn btn-sm btn-success" ui-sref="app.ordersGoodsView({id:o.id})">查看</button>
                            <!--<button class="btn btn-sm btn-info">打印小票</button>-->
                            <div class="btn-group dropdown" dropdown="" ng-if="o.status != 7 && o.status != 9">
                                <button class="btn btn-sm btn-default" dropdown-toggle=""
                                        aria-haspopup="true" aria-expanded="false">更多 <span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu">
                                    <li><a href="" ng-if="o.type==2" ng-click="delivery(o.id,2)">发货</a></li>
                                    <li><a href="" ng-if="o.type==1" ng-click="updateStatus(o.id,2)">配送</a></li>
                                    <li><a href="" ng-if="o.status == 4" ng-click="verifyCode(o.id,5)">核销</a></li>
                                    <li><a href="" ng-if="o.status == 0" ui-sref="app.ordersPriceChange({id:o.id})">修改金额</a></li>
                                    <li><a href="" ng-if="o.status == 2" ui-sref="app.deliveryUpdate({id:o.id})">修改物流信息</a></li>
                                    <li><a href="" ng-if="o.status == 2" ng-click="updateStatus(o.id,3)">确认收货</a></li>
                                    <li><a href="" ng-if="o.status == 0 && o.type==3" ng-click="updateStatus(o.id,6)">交易完成</a></li>
                                    <li><a href="" ng-if="o.status == 5 || o.status == 3" ng-click="updateStatus(o.id,6)">交易完成</a></li>
                                    <li><a href="" ng-if="o.status == 2 && o.type==1" ng-click="updateStatus(o.id,6)">交易完成</a></li>
                                    <li><a href="" ng-if="o.status == 10 && o.type==5" ng-click="updateStatus(o.id,6)">交易完成</a></li>
                                    <!--<li><a href="" ng-if="o.status == 4 || o.status == 5 || o.status == 8 || o.status == 1"  ng-click="updateStatus(o.id,9)">退款</a></li>-->
                                    <!--<li><a href="" ng-if="o.status == 2 || o.status == 3 || o.status == 6"  ng-click="updateStatus(o.id,8)">退货</a></li>-->
                                </ul>
                            </div>
                        </td>
                    </tr>
                    </tbody>
                </table>
                <div ng-if="list.length<=0 && !app.loading" class="padder-v text-center">
                    <span class="h6">~未搜索到任何数据~</span>
                </div>
                <div>
                    <circle-loading ng-if="app.loading"></circle-loading>
                </div>
            </div>
            <footer class="panel-footer">
                <div class="row">
                    <div class="col-sm-4 text-right"></div>
                    <div class="col-sm-4 text-center">
                        <small class="text-muted inline m-t-sm m-b-sm">显示第 {{startRow}} 至 {{endRow}} 项结果，共 {{totalItems}} 项</small>
                    </div>
                    <div class="col-sm-4 text-right text-center-xs">
                        <pagination boundary-links="true" total-items="totalItems" ng-model="currentPage"
                                    ng-change="pageChanged()" max-size="{{maxPageRow}}" class="pagination-sm m-t-none m-b"
                                    previous-text="上一页" next-text="下一页"
                                    first-text="首页" last-text="尾页"></pagination>
                    </div>
                </div>
            </footer>
        </div>
    </div>

</div>